package org.wishwork.api.stock.other.query;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import org.wishwork.api.ExtendBase;

import java.util.List;

/**
 * @description: 其它出入库查询
 * @author: WangYX
 * @create: 2022-04-12 14:03
 * @Version: 1.0.0
 **/
@ToString
@Getter
@EqualsAndHashCode
public class OtherInOutQueryRequest extends ExtendBase {

    /**
     * 非必填
     * 指定线上订单号，和时间段不能同时为空
     */
    private List<String> soIds;

    /**
     * 非必填
     * 单据类型 :其它退货,其它出库,其它进仓
     */
    private List<String> types;

    /**
     * 单据状态，Confirmed=生效，WaitConfirm待审核，Archive=归档，Cancelled=取消
     */
    private String status;

    /**
     * 单据状态，Confirmed=生效，WaitConfirm待审核，Archive=归档，Cancelled=取消
     */
    private Integer wmsCoId;

    protected OtherInOutQueryRequest(Integer pageIndex, Integer pageSize, String modifiedBegin, String modifiedEnd,
                                     List<String> soIds, List<String> types, String status, Integer wmsCoId) {
        super(pageIndex, pageSize, modifiedBegin, modifiedEnd);
        this.soIds = soIds;
        this.types = types;
        this.status = status;
        this.wmsCoId = wmsCoId;
    }

    @Override
    public Builder toBuilder() {
        return new Builder()
                .pageIndex(this.pageIndex)
                .pageSize(this.pageSize)
                .modifiedBegin(this.modifiedBegin)
                .modifiedEnd(this.modifiedEnd)
                .soIds(this.soIds)
                .types(this.types)
                .status(this.status)
                .wmsCoId(this.wmsCoId);
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder extends ExtendBase.Builder<Builder, OtherInOutQueryRequest> {

        private List<String> soIds;
        private List<String> types;
        private String status;
        private Integer wmsCoId;

        @Override
        public Builder modifiedBegin(String modifiedBegin) {
            this.modifiedBegin = modifiedBegin;
            return this;
        }

        @Override
        public Builder modifiedEnd(String modifiedEnd) {
            this.modifiedEnd = modifiedEnd;
            return this;
        }

        @Override
        public Builder pageIndex(Integer pageIndex) {
            this.pageIndex = pageIndex;
            return this;
        }

        @Override
        public Builder pageSize(Integer pageSize) {
            this.pageSize = pageSize;
            return this;
        }

        public Builder soIds(List<String> soIds) {
            this.soIds = soIds;
            return this;
        }

        public Builder types(List<String> types) {
            this.types = types;
            return this;
        }

        public Builder status(String status) {
            this.status = status;
            return this;
        }

        public Builder wmsCoId(Integer wmsCoId) {
            this.wmsCoId = wmsCoId;
            return this;
        }

        @Override
        public OtherInOutQueryRequest build() {
            this.pageIndex = this.pageIndex == null ? 1 : this.pageIndex < 0 ? 1 : this.pageIndex;
            this.pageSize = this.pageSize == null ? 30 : this.pageSize < 0 ? 30 : this.pageSize;
            if (this.soIds == null || this.soIds.size() <= 0) {
                keyIsEmptyTimeHandle(7);
            }
            modifiedTimeHandle(7);
            return new OtherInOutQueryRequest(this.pageIndex, this.pageSize, this.modifiedBegin,
                    this.modifiedEnd, this.soIds, this.types, this.status, this.wmsCoId);
        }
    }
}
